package de.hhbk.feedbackmodul.entities;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 * The persistent class for the umfrage database table.
 * 
 */
@Entity
@Table(name="umfrage")
public class Survey implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(unique=true, nullable=false)
	private int id;
	
	@Column(nullable=false,length=50)
	private String bezeichnung;
	
	@Column(nullable=false)
	private boolean status;

	@Column(nullable=false)
	private boolean autorized;
	
	//bi-directional many-to-one association to Antwortbogen
	@OneToMany(mappedBy="umfrage",fetch=FetchType.EAGER)
	private Set<AnswerSheet> antwortbogens = new HashSet<AnswerSheet>();

	//bi-directional many-to-one association to Fragebogen
    @ManyToOne
	@JoinColumn(name="fk_fragebogen")
	private QuestionSheet fragebogen;

	//bi-directional many-to-one association to User
    @ManyToOne
	@JoinColumn(name="fk_user")
	private User user;

    //bi-directional many-to-one association to Antwortbogen
  	@OneToMany(mappedBy="umfrage",fetch=FetchType.EAGER,cascade=CascadeType.REMOVE)
  	private Set<Tan> tans = new HashSet<Tan>();
    
    public Survey() {
    }

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}
	
	public Set<AnswerSheet> getAntwortbogens() {
		return this.antwortbogens;
	}

	public void setAntwortbogens(Set<AnswerSheet> antwortbogens) {
		this.antwortbogens = antwortbogens;
	}
	
	public QuestionSheet getFragebogen() {
		return this.fragebogen;
	}

	public void setFragebogen(QuestionSheet fragebogen) {
		this.fragebogen = fragebogen;
	}
	
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getBezeichnung() {
		return bezeichnung;
	}

	public void setBezeichnung(String bezeichnung) {
		this.bezeichnung = bezeichnung;
	}

	public boolean isStatus() {
		return status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}

	public boolean isAutorized() {
		return autorized;
	}

	public void setAutorized(boolean autorized) {
		this.autorized = autorized;
	}

	public Set<Tan> getTans() {
		return tans;
	}

	public void setTans(Set<Tan> tans) {
		this.tans = tans;
	}
	
}